<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$xyidArr = array(0 => "", 1 => "X 盘", 2 => "Y盘");
if ($show3D3S == 1 || $show3D3S == 2)
{
    $type = true;
}
else
{
    $type = false;
}
$g_betname_3or5 = judge_type($gametype, true);
unset($chk);
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$ui = new UI_3D(true);
$tpl = new Template2();
$lotto_id = getvar("lotto_id");
if ($show3D3S == 0 && $conf->get("calcbet_{$tbl}") == 1)
{
    $ui->showErrorPage("{$tblName}颁奖过帐中，请稍後再使用本功能！", true);
    exit();
}
if ($curruser['enabled'] == 0)
{
    $ui->showErrorPage("帐号已被停用");
    exit();
}
else if ($lotto_id == "")
{
    $ui->showErrorPage("错误的期数资料");
    exit();
}
else
{
    $lotto_id = intval($lotto_id);
}
$openDate = date("Y-m-d");
$rs = getdb("SELECT open FROM lotto_{$tbl} WHERE id={$lotto_id} LIMIT 1");
if (!$rs->eof)
{
    $openDate = $rs->f[0];
}
$rs->close();
require_once( "class_3d/MyLotto_3d.php" );
require_once( "class_3d/Bet_3d.php" );
require_once( "class_sb/RateConfig_sb.php" );
$MyLotto_3d = new MyLotto_3d($gametype);
if($gametype==25 || $gametype==26)
$RateConfig_sb=new RateConfig_sb($gametype);
$postTime = $conf->get("paper_post_bet");
$today = date("Hi") <= $postTime ? date("Y-m-d", strtotime("-1 day")) : date("Y-m-d");
if ($openDate == $today)
{
    $Bet_3d = new Bet_3d($gametype);
}
else
{
    $Bet_3d = new Bet_3d($gametype, "x");
}
$paperShowOpen = getPaperMinDate(0 - 1);
if ($lotto_3d = $MyLotto_3d->getDataById($lotto_id))
{
    $open = $lotto_3d['open'];
    if (strtotime($lotto_3d['open']) < strtotime($paperShowOpen))
    {
        $ui->showErrorPage("错误的日期资料");
    }
    $round = $show3D3S == 2 || $show3D3S == 3 ? $lotto_3d['round'] : d3($lotto_3d['round']);
    $lotto_id = $lotto_3d['id'];
    $list = "";
    $sum_amount = 0;
    $sum_a1 = 0;
    $sum_b1 = 0;
    $count = 0;
    if ($type && $lotto_3d['calcbet'] == "1")
    {
        $list = "<tr class=\"row1\"><td colspan=\"10\" align=\"center\">" . $tblName . "颁奖过帐中，请稍後再使用本功能</td></tr>";
    }
    else
    {
        $result = $Bet_3d->getMyBetRS($curruser['id'], $lotto_id);
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
        {
            if ($gametype == 20 && $row['bettype'] < 9)
            {
                $xyid = "&nbsp;<font color=\"blue\">" . $xyidArr[$row['xyid']] . "</font>";
            }
            else
            {
                $xyid = "";
            }
            $list .= "<tr class=td2 valign=top>";
            $list .= "<td nowrap>" . date("m-d H:i", $row['createtime']) . "</td>";
            $list .= "<td nowrap>" . $round . "</td>";
			if($gametype==25 || $gametype==26)
				$list .= "<td nowrap>【" . $g_betname_3or5[$row['bettype']] . "】&nbsp;" . $RateConfig_sb->getBetContent($row['bettype'],$row['line_nums']) . "</td>";
			else
            	$list .= "<td nowrap>" . $xyid . "【" . $g_betname_3or5[$row['bettype'] . "_" . $row['subid']] . "】&nbsp;" . nl2br($row['line_nums']) . "</td>";
            $list .= "<td nowrap align=right>" . $g_disk_name[$row['disk']] . "</td>";
            $list .= "<td nowrap align=right>" . floatval($row['rate']) . "</td>";
            $list .= "<td nowrap align=right>" . $row['amount'] . "</td>";
            $list .= "<td nowrap align=right>" . round(floatval($row['a1']), 2) . "</td>";
            $list .= "<td nowrap align=right>" . say_numbercolor($row['b1']) . "</td>";
            $sum_amount += $row['amount'];
            $sum_a1 += $row['a1'];
            $sum_b1 += $row['b1'];
            ++$count;
            if ($row['rame'] == 1)
            {
                $list .= "<td nowrap align=center><font color=red>- 逾时 -</font></td>";
            }
            else if ($row['rame'] == 2)
            {
                $list .= "<td nowrap align=center><font color=red>- 取消 -</font></td>";
            }
            else if ($row['rame'] == 3)
            {
                $list .= "<td nowrap align=center><font color=red>- 异常 -</font></td>";
            }
            else if (chkBet_peace($row))
            {
                $list .= "<td nowrap align=center><font color=blue>- 和局 -</font></td>";
            }
            else
            {
                $list .= "<td nowrap align=right>&nbsp;</td>";
            }
            $list .= "</tr>";
        }
    }
    if ($list == "")
    {
        $list = "<tr class=\"row1\"><td colspan=\"11\" align=\"center\">没有 " . $tblName . " 下注资料！</td></tr>";
    }
    $tpl->load("main", "view.htm");
    $tpl->set(array("count" => $count, "sum_amount" => $sum_amount, "sum_a1" => $sum_a1, "sum_b1" => say_numbercolor($sum_b1), "open" => $open, "round" => $round, "lotto_id" => $lotto_id, "list" => $list, "gametypeStr" => $tblName, "gametype" => $gametype));
    $ui->header();
    $ui->showNews3D($curruser['acl'],1);
    $tpl->show("main");
    $ui->footer();
}
else
{
    $ui->showErrorPage("不存在的{$tblName}期数资料");
    exit();
}
?>